package com.songlanyun.common.enums;

import java.util.Objects;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import com.songlanyun.common.drive.IntegerEnum;

/**
 * 微信
 */
public class VerifyCodeConstant {

    /**
     * 短信验证码类型 0注册 1实名认证 2设置密码
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum VerifyCode implements IntegerEnum<Integer> {
        /**
         * 注册
         */
        REGISTER(0, "注册", "register"),
        /**
         * 实名认证
         */
        VERIFIED(1, "实名认证", "verified"),
        /**
         * 设置密码
         */
        SET_PASSWORD(2, "设置密码", "setPassword"),
        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        private String type;

        VerifyCode(Integer code, String msg, String type) {
            this.code = code;
            this.msg = msg;
            this.type = type;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public String getMsg() {
            return msg;
        }

        public void setType(String type) {
            this.type = type;
        }

        public String getType() {
            return type;
        }

        @JsonCreator
        public static VerifyCode getByCode(int code) {
            for (VerifyCode value : VerifyCode.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

}
